package jwdt.xadmin.custom.action;

import jwdt.common.action.BaseAction;
import jwdt.xadmin.custom.bean.TCar;
import jwdt.xadmin.custom.bean.TCarsq;
import jwdt.xadmin.custom.bean.TCarwh;
import jwdt.xadmin.custom.service.CarManageService;
import jwdt.xadmin.custom.service.CarsqManageService;
import jwdt.xadmin.custom.service.CarwhManageService;
import jwdt.xadmin.system.bean.TUser;

import com.ezerg.db.ext.PageUtil;
import com.ezerg.web.Form;
import com.ezerg.web.Module;
import com.ezerg.web.Page;
import com.ezerg.web.annotation.Controller;
import com.ezerg.web.annotation.RequestMapping;

@Controller("/xadmin/custom")
public class CarManageAction extends BaseAction {

	protected String url = "/xadmin/custom/";
	
	private CarManageService carManageService = (CarManageService)app.getBean("carManageService");
	private CarwhManageService carwhManageService = (CarwhManageService)app.getBean("carwhManageService");
	private CarsqManageService carsqManageService = (CarsqManageService)app.getBean("carsqManageService");
	
	@RequestMapping("/caradd")
	public Page doCarAdd(Form f, Module m) throws Exception {
		//
		f.add("car_cllx", carManageService.getFlmx(15));
		f.add("car_jsy",carManageService.rsxx());
		f.add("car_status",carManageService.getFlmx(14));
		return m.findPage(url + "caradd");
	}
	
	@RequestMapping("/carcheck")
	public Page doCarCheck(Form f, Module m) throws Exception {
		//
		String status = f.getString("status");
		PageUtil pu = (PageUtil)f.copy2Class(PageUtil.class);
		TCar tc = (TCar)f.copy2Class(TCar.class);
		return m.getWritePage(f, carManageService.doList(pu,tc,status).toJson());	
	}
	
	@RequestMapping("/carAddact")
	public Page doCarAddact(Form f, Module m) throws Exception {
		//
		TCar obj = (TCar) f.copy2Class(TCar.class);
		return m.getWritePage(f, carManageService.carAddact(obj));
	}
	
	@RequestMapping("/carEdit")
	public Page doCarEdit(Form f, Module m) throws Exception {
		//
		int id = f.getInt("id");
		f.add("obj", carManageService.carEdit(id));
		f.add("car_cllx",carManageService.getFlmx(15));
		f.add("car_zt",carManageService.getFlmx(14));
		return m.findPage(url + "carEdit");
	}
	
	@RequestMapping("/carEditact")
	public Page doCarEditact(Form f, Module m) throws Exception {
		//
		int id = f.getInt("id");
		TCar obj = (TCar)f.copy2Class(TCar.class);
		return m.getWritePage(f, carManageService.carEditact(obj, id));
	}
	
	@RequestMapping("/carDel")
	public Page doCarDel(Form f, Module m) throws Exception {
		//
		int id = f.getInt("id");
		return m.getWritePage(f, carManageService.carDel(id));
	}
	
	@RequestMapping("/carsqManage")
	public Page doCarsqManage(Form f, Module m) throws Exception {
		return m.findPage(url + "carsqManage");
	}
	
	
	@RequestMapping("/carsqcheck")
	public Page doListCarsq(Form f, Module m) throws Exception {
		String status = f.getString("status");
		PageUtil pu = (PageUtil)f.copy2Class(PageUtil.class);
		TCarsq tc = (TCarsq)f.copy2Class(TCarsq.class);
		return m.getWritePage(f, carManageService.doList(pu,tc,status).toJson());
	}
	
	
	@RequestMapping("/carspManage")
	public Page doCarsqSp(Form f, Module m) throws Exception {
		//
		String sql=" where status=0";
		f.add("carsp",carsqManageService.carSq(sql));
		return m.findPage(url + "carsqsp");
		
	}
	
	@RequestMapping("/listsqCar")
	public Page doListsqCar(Form f, Module m) throws Exception {
		String status = f.getString("status");
		PageUtil pu = (PageUtil)f.copy2Class(PageUtil.class);
		TCarsq tc = (TCarsq)f.copy2Class(TCarsq.class);
		return m.getWritePage(f, carManageService.doList(pu,tc,status).toJson());
	}
	
	@RequestMapping("/carsqSpb")
	public Page doCarsqSpb(Form f, Module m) throws Exception {
		//
		String id = f.getString("id");
		carsqManageService.carsqSpb(f, m, id);
		return m.getRedirectPage(url + "carspManage.do");
	}
	
	@RequestMapping("/carsqSpt")
	public Page doCarsqSpt(Form f, Module m) throws Exception {
		String id = f.getString("id");
		carsqManageService.carsqSpt(f, m, id);
		return m.getRedirectPage(url + "carspManage.do");
	}
	
	@RequestMapping("/carsqXz")
	public Page doCarsqXz(Form f, Module m) throws Exception {
		//
		f.add("carsqXz",carsqManageService.carsqXz(f, m));
		f.add("pager",carManageService.pagecar(f, m));
		return m.findPage(url + "carsqxz");
	}
	
	@RequestMapping("/carsqXzbm")
	public Page doCarsqXzbm(Form f, Module m) throws Exception {
		//
		f.add("carsqXzbm", carsqManageService.carsqXzbm());
		f.add("pager",carManageService.pagecar(f, m));
		return m.findPage(url + "carsqxzbm");
	}
	
	@RequestMapping("/carsqAdd")
	public Page doCarsqAdd(Form f, Module m) throws Exception {
		//
		f.add("cpxx", carsqManageService.cpxxSq());
		return m.findPage(url + "carsqadd");
	}
	
	@RequestMapping("/carsqAddact")
	public Page doCarsqAddact(Form f, Module m) throws Exception {
		//
		TCarsq obj = (TCarsq) f.copy2Class(TCarsq.class);
		TUser userInfo = (TUser) f.getSession("userInfo");
		return m.getWritePage(f, carsqManageService.carsqAddact(obj,userInfo));
		
	}
	
	@RequestMapping("/carsqEdit")
	public Page doCarsqEdit(Form f, Module m) throws Exception {
		//
		int id = f.getInt("id");
		f.add("obj", carsqManageService.carsqEdit(id));
		f.add("cllx",carManageService.getFlmx(15));
		f.add("Qjtype",carManageService.getFlmx(14));
		return m.findPage(url + "carsqEdit");
	}
	
	@RequestMapping("/carsqEditact")
	public Page doCarsqEditact(Form f, Module m) throws Exception {
		//
		int id = f.getInt("id");
		TCarsq obj = (TCarsq)f.copy2Obj(TCarsq.class);
		return m.getWritePage(f, carsqManageService.carsqEditact(obj,id));
	}

	@RequestMapping("/carsqDel")
	public Page doCarsqDel(Form f, Module m) throws Exception {
		//
		int id = f.getInt("id");
		return m.getWritePage(f,carsqManageService.carsqDel(id));
	}
	
	@RequestMapping("/listCarwh")
	public Page doListCarwh(Form f, Module m) throws Exception {
		PageUtil pu = (PageUtil)f.copy2Class(PageUtil.class);
		TCarwh tc = (TCarwh)f.copy2Class(TCarwh.class);
		return m.getWritePage(f, carManageService.doList(pu,tc).toJson());
	}
	
	
	@RequestMapping("/carwhAdd")
	public Page doCarwhAdd(Form f, Module m) throws Exception {
		//
		
		f.add("car_jbr",carManageService.rsxx());
		f.add("cpxx", carwhManageService.cpxxWh());
		f.add("car_whlx",carManageService.getFlmx(17));
		return m.findPage(url + "carwhadd");
	}
	
	@RequestMapping("/carwhAddact")
	public Page doAddact(Form f, Module m) throws Exception {
		TCarwh obj = (TCarwh) f.copy2Class(TCarwh.class);
		return m.getWritePage(f, carwhManageService.carwhAddact(obj));
	}

	
	@RequestMapping("/carwhEdit")
	public Page doCarwhEdit(Form f, Module m) throws Exception {
		//
		int id = f.getInt("id");
		f.add("obj",carwhManageService.carwhEdit(id));
		f.add("cpxx",carwhManageService.cpxxWh());
		f.add("car_whlx",carManageService.getFlmx(17));
		return m.findPage(url + "carwhEdit");
	}
	
	
	@RequestMapping("/carwhEditact")
	public Page doCarwhEditact(Form f, Module m) throws Exception {
		//
		int id = f.getInt("id");
		TCarwh obj = (TCarwh)f.copy2Class(TCarwh.class);
		return m.getWritePage(f, carwhManageService.carwhEditact(obj,id));
	}
	
	@RequestMapping("/carwhDel")
	public Page doCarwhDel(Form f, Module m) throws Exception {
		//
		int id = f.getInt("id");
		return m.getWritePage(f, carwhManageService.carwhDel(id));
	}

	
	
	
	
}